home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Installers / Smaller Installer 2.0.1 / Preinstalled version / Examples / Hook Procedure Examples / TestGestaltHook / TestGestaltHook.c next >
Encoding:
C/C++ Source or Header  |  1996-07-26  |  3.7 KB  |  131 lines  |  [TEXT/CWIE]

  1. /******************************************************************************
  2.     Smaller Installer © 1995 Bill Goodman, All Rights Reserved
  3. *******************************************************************************
  4.  
  5. Test Gestalt Example
  6.  
  7. This installer hook procedure demonstrates using a Gestalt call to test a
  8. system feature and enable one of two installation groups based on the result.
  9. In this example, the hook enables group "O" if the system software version is
  10. less than 7.1 and enable group "P" if the version is 7.1 or higher.
  11.  
  12. To build this hook procedure, compile this code and create a code resource
  13. (Type:SICR, ID:501, non-preloaded, nonpurgeable, unlocked, unprotected,
  14. non-sysheap). Add this resource to the "TestGestaltHook.rsrc" file. Copy all
  15. the resources in "TestGestaltHook.rsrc" to your installer's resource file.
  16.  
  17. ******************************************************************************/
  18.  
  19. // This file is compatible with version 2.1 of the universal headers
  20. #include <GestaltEqu.h>
  21.  
  22. #ifdef __MWERKS__
  23. #include <A4Stuff.h>
  24. #endif
  25.  
  26. #ifdef THINK_C
  27. #include <SetUpA4.h>
  28. #endif
  29.  
  30. #include "SIHookProc.h"
  31.  
  32.  
  33. /******************************************************************************
  34.     Function Prototypes
  35. ******************************************************************************/
  36. void FirstFunction(void);
  37.  
  38.  
  39. /******************************************************************************
  40.     Constant Definitions
  41. ******************************************************************************/
  42. #define groupOMask    0x4000    // Group "O" selection mask
  43. #define groupPMask    0x8000    // Group "P" selection mask
  44.  
  45.  
  46. /******************************************************************************
  47.     Variable Definitions
  48. ******************************************************************************/
  49. SIHookParmBlk *gParms;    // Global pointer to parameter block
  50.  
  51.  
  52. /*****************************************************************************/
  53. pascal void main(
  54.         SIHookParmBlk *parmBlk    // Pointer to parameter block
  55.         )
  56. /******************************************************************************
  57.     This is the main entry point for the installer hook procedure.
  58. ******************************************************************************/
  59. {
  60. #ifdef __MWERKS__
  61. long holdA4;
  62. #endif
  63.  
  64. // Set up access to global variables
  65. #ifdef THINK_C
  66. RememberA0();
  67. SetUpA4();
  68. #endif
  69.  
  70. #ifdef __MWERKS__
  71. holdA4 = SetCurrentA4();
  72. #endif
  73.  
  74. gParms = parmBlk;
  75.  
  76. switch (gParms->function)
  77.     {
  78.     case siHookFirst:
  79.         FirstFunction();
  80.         break;
  81.     }
  82.  
  83. // Restore original A4 value
  84. #ifdef THINK_C
  85. RestoreA4();
  86. #endif
  87.  
  88. #ifdef __MWERKS__
  89. SetA4(holdA4);
  90. #endif
  91. }
  92.  
  93.  
  94. /*****************************************************************************/
  95. void FirstFunction(void)
  96. /******************************************************************************
  97.     Input parameters:
  98.         "targetVRefNum"    Volume reference number of target volume
  99.         "groupAPFlags"        Groups currently selected
  100.         "groupQUSel"
  101.         "groupVZSel"
  102.         "group32Flags"
  103.         "group64Flags"
  104.         "group96Flags"
  105.         "groupEnvironFlags"
  106.  
  107.     Returns:
  108.         "groupAPFlags"        Updated installation groups
  109.         "groupQUSel"
  110.         "groupVZSel"
  111.         "group32Flags"
  112.         "group64Flags"
  113.         "group96Flags"
  114.         "result"                Hook result code (siHookNoErr, siHookQuit)
  115.  
  116.     This function is called once when the installer is launched.
  117. ******************************************************************************/
  118. {
  119. OSErr error;
  120. long feature;
  121.  
  122. gParms->groupAPFlags &= ~(groupOMask | groupPMask);    // Clear both flags
  123.  
  124. // Use Gestalt to obtain system version. Assume < 7.1 if Gestalt fails.
  125. error = Gestalt(gestaltSystemVersion, &feature);
  126. if (!error && (feature >= 0x0710))
  127.     gParms->groupAPFlags |= groupPMask;    // 7.1 or higher
  128. else
  129.     gParms->groupAPFlags |= groupOMask;    // Lower than 7.1
  130. }
  131.